Load ResetTabs,RefLinks,ListBlock,References,AttachData,OBJEPanes,SourceButtons

! -------------- Start Template -----------------
GoSub ResetTabs,0
GoSub OBJEPanes,"All"
DropTypes INDI,FAM

#path=@FILE
#form=@FILE.FORM
#formType=@FILE.FORM.MEDI
#title=@FILE.TITL

cell GroupBox,local("Multimedia Link")
  width -1

  newline
  #details="No"
  if #form="url"
    tab 1
    cell Multimedia
    set url #path width -1 font "Hyperlink Text"
    if #title<>""
      text #title
    else
      text #path
    endif
    set objectImage @this imageposition left
    sizetofit -1

    set alignment left height #imageHeight$
    set help local("Click to open this URL link in your browser application.") 
  else
    newline
    cell Multimedia
    #padding=5
    set objectFull @this mmFormat #form width -1
    set imageposition imageonly
    #iWidth=#imageWidth$/72
    #iHeight=#imageHeight$/72
    #ppi=#imagePPI$
    #maxScale=(#cellWidth$-2*#padding)/#imageWidth$
    if #scale>#maxScale
      #makeWidth=#cellWidth$-2*#padding
      #makeHeight=#makeWidth*#imageHeight$/#imageWidth$+2*#padding
    else if #scale>.1
      #makeWidth=#imageWidth$*#scale
      #makeHeight=#imageHeight$*#scale
    else
      #makeWidth=#cellWidth$-2*#padding
      #makeHeight=#makeWidth*#imageHeight$/#imageWidth$+2*#padding
    endif
    
    ! handle non-image objects
    if #imageType$="noimage"
      set height #imageHeight$+2*#padding
      if #appName$="GEDitCOM II"
        set text local("No image representation. Click to open in another application")
        help local("Click to open in a helper application.")
        help " "&local("You can configure which application opens each type of multimedia object.")
      else
        set text local("No image representation for this multimedia object.")
      endif
      set font "Static Text" imageposition left alignment left
    else if #imageType$="nopermission"
      set height #imageHeight$+2*#padding
      set text local("You do not have permission to view this multimedia object.")
      set font "Static Text" imageposition left alignment left
    else if #imageType$="notfound"
      set height #imageHeight$+2*#padding
      set text local("Multimedia file not found (click to fix)")
      set font "Static Text" imageposition left alignment left
      set MenuLink "Attach Multimedia"
      help local("Click to link this record to a multimedia object.")
    else if #imageType$="image"
      set imageWidth #makeWidth
      set height #makeHeight+2*#padding
      #details="Yes"
      if #appName$="GEDitCOM II"
        help local("Click to open in a helper application.")
        help " "&local("You can configure which application opens each type of multimedia object.")
      else
        help local("Click to view this image in the Zoom pane")
        set RecordLink @id PaneID "Zoom"
      endif
    else
      set imageWidth #makeWidth
      set height #makeHeight+2*#padding
      ! thumbnail
      help local("The file for this image was not found.")
      help " "&local("This image is a thumbnail that was generated when it was available.")
      set ScriptLink "Thumbnail.gcscpt" ScriptType format
    endif
  endif

  newline 6
  Show FILE #form,#formType
  if #details="Yes"
    newline
    cell static,local("Details")&":"
    set tabwidth -1 alignment right
    cell static
    if #ppi>0
      #iWidth=int(100*#iWidth)/100
      #iHeight=int(100*#iHeight)/100
      text local("Size")&" "&#iWidth&" in X "&#iHeight&" in"
      text " (ppi: "&#ppi&")"
    else
      #iWidth=int(72*#iWidth)
      #iHeight=int(72*#iHeight)
      text #iWidth&" X "&#iHeight&" pixel thumbnail"
    endif
    width -1
    Show _SCALE
  else
    Hide _SCALE
  endif

EndGroup

! --------- NOTEs, SOURs, OBJEs, and _LOGs -----------
if @_REF<>""
  cell GroupBox,local("Linked Records")
    width -1
    newline -#lineSkip
    gosub RefLinks,local("Linked to"),local("All Linked Records")
  EndGroup
endif
#numSOURs=@count.SOUR
gosub References,"_LOG"

cell GroupBox,local("Geographical Data and Keywords")
  width -1
  newline -3
  Show _LOC
  Show _KEY
  ShowAll _KEY
endGroup

! --------- Attach links
newline
cell GroupBox,local("Attach")
  width -1
  newline -#lineSkip-3
  #lineSkip=0
  Show NOTE
  Show SOUR
  gosub AttachData
  GoSub SourceButtons,"true",#numSOURs
EndGroup
#lineSkip=#lineSkip$

! -------- Additional Data ------------
if more is true
  ClearTabs
  gosub ResetTabs,50
  cell GroupBox,local("Additional Data")
    width -1
    ShowAll CHAN
	Show _DIST "label"
    ShowAll all
  EndGroup
endif

optionalTag RIN,local(RIN)
optionalTag REFN,local(REFN)
optionalTag _KEY,local(_KEY)

